//#define DEBUG
#include <cstdio>
#define MODS 998244353
#define MAXN 5000

using namespace std;

int main() {
#ifdef DEBUG
  freopen("1.in", "r", stdin);
  freopen("1.out", "w", stdout);
#endif

  static long long s[MAXN+1][MAXN+1], fact[MAXN+1], power[MAXN+1];
  int n;
  scanf("%d", &n);
  s[0][0]=1;
  for (int i=1; i<=n; i++) {
    s[i][0]=0;
    for (int j=1; j<=i; j++) {
      s[i][j]=(s[i-1][j]*j%MODS+s[i-1][j-1])%MODS;
    }
  }

  fact[0]=1;
  power[0]=1;
  for (int i=1; i<=n; i++) {
    fact[i] = fact[i-1]*i%MODS;
    power[i] = power[i-1]*2%MODS;
  }

#ifdef DEBUG
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=i; j++) {
      printf("%lld ", s[i][j]);
    }
    printf("\n");
  }

  long long ans=0;
  for (int j=0; j<=n; j++) {
    long long sum=0;
    for (int i=j; i<=n; i++) {
      sum = (sum+s[i][j])%MODS;
    }
    ans = (ans+sum*fact[j]%MODS*power[j]%MODS)%MODS;
  }
#else
  long long ans=0;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=i; j++) {
      ans = (ans+s[i][j]*fact[j]%MODS*power[j]%MODS)%MODS;
    }
  }
#endif

  printf("%lld", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
